Class java.net.HttpURLConnection
All Packages Class Hierarchy This Package Previous Next Index
Class java.net.HttpURLConnection
Object
|
+----URLConnection
|
+----java.net.HttpURLConnection
- public abstract class HttpURLConnection
- extends URLConnection
A URLConnection with support for HTTP-specific features. See
the spec for
details.
- Since:
- JDK1.1
-
HTTP_ACCEPTED
-
-
HTTP_BAD_GATEWAY
-
-
HTTP_BAD_METHOD
-
-
HTTP_BAD_REQUEST
- 4XX: client error
-
HTTP_CLIENT_TIMEOUT
-
-
HTTP_CONFLICT
-
-
HTTP_CREATED
-
-
HTTP_ENTITY_TOO_LARGE
-
-
HTTP_FORBIDDEN
-
-
HTTP_GATEWAY_TIMEOUT
-
-
HTTP_GONE
-
-
HTTP_INTERNAL_ERROR
-
-
HTTP_LENGTH_REQUIRED
-
-
HTTP_MOVED_PERM
-
-
HTTP_MOVED_TEMP
-
-
HTTP_MULT_CHOICE
- 3XX: relocation/redirect
-
HTTP_NOT_ACCEPTABLE
-
-
HTTP_NOT_AUTHORITATIVE
-
-
HTTP_NOT_FOUND
-
-
HTTP_NOT_MODIFIED
-
-
HTTP_NO_CONTENT
-
-
HTTP_OK
- 2XX: generally "OK"
-
HTTP_PARTIAL
-
-
HTTP_PAYMENT_REQUIRED
-
-
HTTP_PRECON_FAILED
-
-
HTTP_PROXY_AUTH
-
-
HTTP_REQ_TOO_LONG
-
-
HTTP_RESET
-
-
HTTP_SEE_OTHER
-
-
HTTP_SERVER_ERROR
- 5XX: server error
-
HTTP_UNAUTHORIZED
-
-
HTTP_UNAVAILABLE
-
-
HTTP_UNSUPPORTED_TYPE
-
-
HTTP_USE_PROXY
-
-
HTTP_VERSION
-
-
method
-
-
responseCode
-
-
responseMessage
-
-
java.net.HttpURLConnection(URL)
- Constructor for the URLStreamHandler.
-
disconnect()
- Close the connection to the server.
-
getFollowRedirects()
-
-
getRequestMethod()
- Get the request method.
-
getResponseCode()
- Gets HTTP response status.
-
getResponseMessage()
- Gets the HTTP response message, if any, returned along with the
response code from a server.
-
setFollowRedirects(boolean)
- Sets whether HTTP redirects (requests with response code 3xx) should
be automatically followed by this class.
-
setRequestMethod(String)
- Set the method for the URL request, one of:
- GET
- POST
- HEAD
- OPTIONS
- PUT
- DELETE
- TRACE
are legal, subject to protocol restrictions.
-
usingProxy()
- Indicates if the connection is going through a proxy.
HTTP_ACCEPTED
public static final int HTTP_ACCEPTED
HTTP_BAD_GATEWAY
public static final int HTTP_BAD_GATEWAY
HTTP_BAD_METHOD
public static final int HTTP_BAD_METHOD
HTTP_BAD_REQUEST
public static final int HTTP_BAD_REQUEST
- 4XX: client error
HTTP_CLIENT_TIMEOUT
public static final int HTTP_CLIENT_TIMEOUT
HTTP_CONFLICT
public static final int HTTP_CONFLICT
HTTP_CREATED
public static final int HTTP_CREATED
HTTP_ENTITY_TOO_LARGE
public static final int HTTP_ENTITY_TOO_LARGE
HTTP_FORBIDDEN
public static final int HTTP_FORBIDDEN
HTTP_GATEWAY_TIMEOUT
public static final int HTTP_GATEWAY_TIMEOUT
HTTP_GONE
public static final int HTTP_GONE
HTTP_INTERNAL_ERROR
public static final int HTTP_INTERNAL_ERROR
HTTP_LENGTH_REQUIRED
public static final int HTTP_LENGTH_REQUIRED
HTTP_MOVED_PERM
public static final int HTTP_MOVED_PERM
HTTP_MOVED_TEMP
public static final int HTTP_MOVED_TEMP
HTTP_MULT_CHOICE
public static final int HTTP_MULT_CHOICE
- 3XX: relocation/redirect
HTTP_NOT_ACCEPTABLE
public static final int HTTP_NOT_ACCEPTABLE
HTTP_NOT_AUTHORITATIVE
public static final int HTTP_NOT_AUTHORITATIVE
HTTP_NOT_FOUND
public static final int HTTP_NOT_FOUND
HTTP_NOT_MODIFIED
public static final int HTTP_NOT_MODIFIED
HTTP_NO_CONTENT
public static final int HTTP_NO_CONTENT
HTTP_OK
public static final int HTTP_OK
- 2XX: generally "OK"
HTTP_PARTIAL
public static final int HTTP_PARTIAL
HTTP_PAYMENT_REQUIRED
public static final int HTTP_PAYMENT_REQUIRED
HTTP_PRECON_FAILED
public static final int HTTP_PRECON_FAILED
HTTP_PROXY_AUTH
public static final int HTTP_PROXY_AUTH
HTTP_REQ_TOO_LONG
public static final int HTTP_REQ_TOO_LONG
HTTP_RESET
public static final int HTTP_RESET
HTTP_SEE_OTHER
public static final int HTTP_SEE_OTHER
HTTP_SERVER_ERROR
public static final int HTTP_SERVER_ERROR
- 5XX: server error
HTTP_UNAUTHORIZED
public static final int HTTP_UNAUTHORIZED
HTTP_UNAVAILABLE
public static final int HTTP_UNAVAILABLE
HTTP_UNSUPPORTED_TYPE
public static final int HTTP_UNSUPPORTED_TYPE
HTTP_USE_PROXY
public static final int HTTP_USE_PROXY
HTTP_VERSION
public static final int HTTP_VERSION
method
protected java.lang.String method
-
- Since:
JDK1.1
responseCode
protected int responseCode
-
- Since:
JDK1.1
responseMessage
protected java.lang.String responseMessage
-
- Since:
JDK1.1
HttpURLConnection
protected HttpURLConnection(URL u)
- Constructor for the URLStreamHandler.
- Since:
- JDK1.1
disconnect
public abstract void disconnect()
- Close the connection to the server.
- Since:
- JDK1.1
getFollowRedirects
public static boolean getFollowRedirects()
-
- Since:
- JDK1.1
getRequestMethod
public java.lang.String getRequestMethod()
- Get the request method.
- Since:
- JDK1.1
getResponseCode
public int getResponseCode() throws IOException
- Gets HTTP response status. From responses like:
HTTP/1.0 200 OK
HTTP/1.0 401 Unauthorized
Extracts the ints 200 and 401 respectively.
Returns -1 if none can be discerned
from the response (i.e., the response is not valid HTTP).
- Throws: IOException
- if an error occurred connecting to the server.
- Since:
- JDK1.1
getResponseMessage
public java.lang.String getResponseMessage() throws IOException
- Gets the HTTP response message, if any, returned along with the
response code from a server. From responses like:
HTTP/1.0 200 OK
HTTP/1.0 404 Not Found
Extracts the Strings "OK" and "Not Found" respectively.
Returns null if none could be discerned from the responses
(the result was not valid HTTP).
- Throws: IOException
- if an error occurred connecting to the server.
- Since:
- JDK1.1
setFollowRedirects
public static void setFollowRedirects(boolean set)
- Sets whether HTTP redirects (requests with response code 3xx) should
be automatically followed by this class. True by default. Applets
cannot change this variable.
- Since:
- JDK1.1
setRequestMethod
public void setRequestMethod(String method) throws ProtocolException
- Set the method for the URL request, one of:
- GET
- POST
- HEAD
- OPTIONS
- PUT
- DELETE
- TRACE
are legal, subject to protocol restrictions. The default
method is GET.
- Throws: ProtocolException
- if the method cannot be reset or if
the requested method isn't valid for HTTP.
- Since:
- JDK1.1
usingProxy
public abstract boolean usingProxy()
- Indicates if the connection is going through a proxy.
- Since:
- JDK1.1
All Packages Class Hierarchy This Package Previous Next Index